package org.fast.develop.logicflow.core;

import org.fast.develop.logicflow.builder.LogicFlowBuilderFactory;
import org.fast.develop.logicflow.core.meta.builder.ElementFactory;
import org.fast.develop.logicflow.core.meta.base.Resource;

/**
 * @author 莫寅
 * @createTime 2022-11-24 23:21
 * @desc：
 */
public class LogicFlowConfiguration {


    private ElementFactory elementFactory;

    private LogicFlowBuilderFactory logicFlowBuilderFactory;

    private static LogicFlowConfiguration defaultLogicFlowConfiguration;

    public static LogicFlowConfiguration getInstance(){
        return defaultLogicFlowConfiguration;
    }

    public LogicFlowConfiguration() {
        this.elementFactory = new ElementFactory();
        this.logicFlowBuilderFactory = new LogicFlowBuilderFactory(this);
        if(defaultLogicFlowConfiguration == null){
            defaultLogicFlowConfiguration = this;
        }
    }



    public void registerElement(String name, Class<? extends Resource> resourceClass){
        elementFactory.registerElement(name, resourceClass);
    }




    public LogicFlowBuilderFactory getLogicFlowBuilderFactory() {
        return logicFlowBuilderFactory;
    }

    public ElementFactory getElementFactory() {
        return elementFactory;
    }
}
